package org.linlinjava.litemall.db.service;

import org.linlinjava.litemall.db.dao.AgedmallStoreMapper;
import org.linlinjava.litemall.db.dao.app.AppStoreMapper;
import org.linlinjava.litemall.db.domain.AgedmallBusiAdmin;
import org.linlinjava.litemall.db.domain.AgedmallDeliveryManInfo;
import org.linlinjava.litemall.db.domain.AgedmallStore;
import org.linlinjava.litemall.db.domain.AgedmallStoreExample;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

@Service
public class AgedmallStoreService {

    @Resource
    private AgedmallStoreMapper agedmallStoreMapper;
    @Resource
    private AppStoreMapper appStoreMapper;

    public AgedmallStore findStoreById(long id) {
        AgedmallStoreExample agedmallStoreExample = new AgedmallStoreExample();
        agedmallStoreExample.or().andIdEqualTo(id);
        return agedmallStoreMapper.selectOneByExample(agedmallStoreExample);
    }
    public List<AgedmallStore> getStoreListByIntIds(List<Integer> storeIds) {
        List<Long> list = new ArrayList<>();
        storeIds.stream().forEach(s->{
            list.add(Long.parseLong(s.toString()));
        });
        return getStoreListByIds(list);
    }
    public List<AgedmallStore> getStoreListByIds(List<Long> storeIds) {
        if(storeIds.size() == 0) {
            return new ArrayList<>();
        }
        AgedmallStoreExample example = new AgedmallStoreExample();
        example.or().andIdIn(storeIds);
        List<AgedmallStore> list = agedmallStoreMapper.selectByExample(example);
        return list;
    }

    public AgedmallStore getAgedmallBusiAdminByStoreId(long storeId) {
        return appStoreMapper.getAgedmallBusiAdminByStoreId(storeId);
    }

    public AgedmallDeliveryManInfo getAgedmallDeliveryManInfoByStoreId(long storeId) {
        return appStoreMapper.getAgedmallDeliveryManInfoByStoreId(storeId);
    }

}
